#include "Thread.hpp"
#include "threadpool.hpp"
#include "task.hpp"
#include <cstdlib>
#include <ctime>
#include <unistd.h>

using namespace std;

int main()
{
    srand((unsigned int)time(nullptr));
    //threadPool<int>* tp = new threadPool<int>;
    //threadPool<Task>* tp = new threadPool<Task>;
    threadPool<Task>::getInstance();
    sleep(1);
    while (true)
    {
        //int data = rand() % 10 + 1;
        int x = rand() % 10 + 1;
        int y = rand() % 10 + 1;
        int opIndex = rand() % oper.size();
        Task t(x, y, oper[opIndex], Compute);
        //tp->push(data);
        //tp->push(t);
        threadPool<Task>::getInstance()->push(t);
        cout << "main thread 录入了一个任务: " << t.toTaskString() << endl;
        sleep(3);
    }
    return 0;
}
/*
线程池基本结构: 线程个数 存放线程(指针)的数组 任务队列 互斥锁 条件变量
*/